package routers

import (
	"GoWeb/001_bubble/controller"
	"github.com/gin-gonic/gin"
)

func SetupRouters() *gin.Engine {
	r := gin.Default()

	//告诉 gin 框架模本文件引用的静态文件去哪里找
	r.Static("/static", "static")
	//解析模版，告诉 gin 框架去哪里找模版文件
	r.LoadHTMLGlob("templates/index.html")

	r.GET("/", controller.IndexHandler)

	//v1
	v1Group := r.Group("v1")
	{
		//待办事项
		//添加
		v1Group.POST("/todo", controller.CreateATodo)
		//查看所有代办事项
		v1Group.GET("/todo", controller.GetTodoList)
		//查看某一个待办事项
		v1Group.GET("/todo/:id", controller.GetATodo)
		//修改
		v1Group.PUT("/todo/:id", controller.UpdateATodo)
		//删除
		v1Group.DELETE("/todo/:id", controller.DeleteATodo)
	}
	return r
}
